package com.xnyzc.lhy.mis.controller.cmsapi.menu;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.mis.entity.param.cms.OfficeParam;
import com.xnyzc.lhy.mis.entity.result.menu.Menu;
import com.xnyzc.lhy.mis.service.cms.menu.MenuService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 机构相关
 *
 * @Author: wangshuo
 * @Date: 2019-08-07 14:11
 */
@RestController
@RequestMapping("/cmsapi/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    /**
     * 获取菜单列表
     *
     * @return
     */
    @ApiOperation(value = "获取目录列表", notes = "获取目录列表")
    @PostMapping(value = "/getMenuList")
    public Rv getMenuList(
            @ApiParam(name = "officeParam", value = "接入传参") @RequestBody OfficeParam officeParam
    ) {
        return Rv.wrap(menuService.getMenuList(officeParam));
    }

    /**
     * 获取菜单详情
     *
     * @return
     */
    @ApiOperation(value = "获取菜单详情", notes = "获取菜单详情")
    @PostMapping(value = "/getMenuDetail")
    public Rv getMenuDetail(
            @ApiParam(name = "menu", value = "菜单接入传参") @RequestBody Menu param
    ) {
        return Rv.wrap(menuService.getMenuDetail(param));
    }

    /**
     * 获取拉取目录结构列表
     * @param currentId 当前菜单id
     * @return
     */
    @ApiOperation(value = "获取拉取目录结构列表", notes = "获取拉取目录结构列表")
    @GetMapping(value = "/getMenuTreeData")
    public Rv getMenuTreeData(
            @RequestParam(value = "currentId") Long currentId
    ) {
        return Rv.wrap(menuService.getMenuTreeData(currentId));
    }

    /**
     * 新增、修改菜单
     *
     * @return
     */
    @ApiOperation(value = "新增、修改菜单", notes = "新增、修改菜单")
    @PostMapping(value = "/getUpdateMenu")
    public Rv getUpdateMenu(
            @ApiParam(name = "menu", value = "菜单接入传参") @RequestBody Menu menu
    ) {
        return Rv.wrap(menuService.getUpdateMenu(menu));
    }

    /**
     * 删除菜单
     *
     * @return
     */
    @ApiOperation(value = "删除菜单", notes = "删除菜单")
    @PostMapping(value = "/getDeleteMenu")
    public Rv getDeleteMenu(
            @ApiParam(name = "menu", value = "菜单接入传参") @RequestBody Menu menu
    ) {
        return Rv.wrap(menuService.getDeleteMenu(menu));
    }


}
